package cn.xiaobai.j2exe.utils;

import javafx.application.Platform;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

/**
 * 工作线程池
 *
 * @Author yangdaji
 * @Date 2023/12/24
 * @PackageName cn.xiaobai.utils
 * @ClassName TaskPool
 */
public class TaskPool {

    public static final ExecutorService executorService = Executors.newFixedThreadPool(5);


    public static Future<?> submit(Runnable task) {
        return executorService.submit(task);
    }

    public static Future<?> submitFx(Runnable task) {
        return executorService.submit(() -> {
            Platform.runLater(task);
        });
    }

}
